package br.gendi.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;

import br.gendi.beans.BaseGenomica;

public class Util {
	
	public static ArrayList<BaseGenomica> basesConfiguradas() throws FileNotFoundException, IOException, ClassNotFoundException {
		
		File f = new File(".\\saves\\");
		if (!f.exists()) {
			f.mkdirs();
			return null;
		}
		
		File lista[] = f.listFiles();

		if (lista == null || lista.length == 0)
			return null;

		ArrayList<BaseGenomica> listaRetorno = new ArrayList<BaseGenomica>();
		for (int i=0; i<lista.length; i++) 
		{
			ObjectInputStream in = new ObjectInputStream(new FileInputStream(lista[i])); 
			final BaseGenomica base = (BaseGenomica)in.readObject();
			listaRetorno.add(base);
			
		}
		return listaRetorno;
	}
	
}
